//
//  CarVerifyViewCell.swift
//  TrafficViolation
//
//  Created by eaglelive on 2017/5/19.
//  Copyright © 2017年 eaglelive. All rights reserved.
//

import UIKit

class CarVerifyViewCell : UITableViewCell{
    var btn1,btn2,btn3,btn4,submitBtn:UIButton!
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCellSelectionStyle.none
        self.layer.borderWidth = 0
        
        let vc = VerifyCarController()
        
        let backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: self.sd_width, height: sd_height))
        self.addSubview(backgroundView)
        backgroundView.snp.makeConstraints { (make) in
            make.left.equalTo(self)
            make.top.equalTo(self)
            make.right.equalTo(self)
            make.bottom.equalTo(self)
        }
        let cvView = CommonView()
        backgroundView.addSubview(cvView)
        cvView.snp.makeConstraints { (make) in
            make.left.equalTo(backgroundView.snp.left)
            make.top.equalTo(backgroundView.snp.top)
            make.width.equalTo(kScreenW - 15)
            make.height.equalTo(commonViewH)
        }
        let carLicense = UILabel.init(frame: CGRect(x: 5, y: commonViewH+oTop, width: oLabelW, height: oLabelH))
        carLicense.font = UIFont.systemFont(ofSize: 14)
        carLicense.text = "行驶证信息"
        backgroundView.addSubview(carLicense)
        //证件照片
        btn1 = UIButton.init(frame: CGRect(x: oLabelW, y: commonViewH+2*oTop+oLabelH, width: oImgW, height: oImgH))
        btn1.setBackgroundImage(UIImage(named:"xingshizheng1"), for: .normal)
        btn1.tag = 1
        btn1.addTarget(vc, action: #selector(vc.choicePicture(sender:)), for: UIControlEvents.touchUpInside)
        backgroundView.addSubview(btn1)
        
        btn2 = UIButton.init(frame: CGRect(x: oLabelW, y: commonViewH+3*oTop+oLabelH+oImgH, width: oImgW, height: oImgH))
        btn2.setBackgroundImage(UIImage(named:"xingshizheng2"), for: .normal)
        btn2.tag = 2
        btn2.addTarget(vc, action: #selector(vc.choicePicture(sender:)), for: UIControlEvents.touchUpInside)
        backgroundView.addSubview(btn2)
        
        let driveLicense = UILabel.init(frame: CGRect(x: 5, y: commonViewH+4*oTop+oLabelH+2*oImgH, width: oLabelW, height: oLabelH))
        driveLicense.font = UIFont.systemFont(ofSize: 14)
        driveLicense.text = "驾驶证信息"
        backgroundView.addSubview(driveLicense)
        
        btn3 = UIButton.init(frame: CGRect(x: oLabelW, y: commonViewH+5*oTop+2*oLabelH+2*oImgH, width: oImgW, height: oImgH))
        btn3.setBackgroundImage(UIImage(named:"jiashizheng1"), for: .normal)
        btn3.tag = 3
        btn3.addTarget(vc, action: #selector(vc.choicePicture(sender:)), for: UIControlEvents.touchUpInside)
        backgroundView.addSubview(btn3)
        
        btn4 = UIButton.init(frame: CGRect(x: oLabelW, y: commonViewH+6*oTop+2*oLabelH+3*oImgH, width: oImgW, height: oImgH))
        btn4.setBackgroundImage(UIImage(named:"jiashizheng2"), for: .normal)
        btn4.tag = 4
        btn4.addTarget(vc, action: #selector(vc.choicePicture(sender:)), for: UIControlEvents.touchUpInside)
        backgroundView.addSubview(btn4)
        
        submitBtn = UIButton.init(frame: CGRect(x: 20, y: commonViewH+7*oTop+2*oLabelH+4*oImgH, width: kScreenW - 40, height: cellH))
        submitBtn.setTitleColor(UIColor.white, for: .normal)
        submitBtn.setTitle("保存", for: .normal)
        submitBtn.backgroundColor = appMainColor
        submitBtn.showsTouchWhenHighlighted = true
        submitBtn.layer.cornerRadius = 10
        submitBtn.addTarget(vc, action: #selector(vc.submitAuth(sender:)), for: UIControlEvents.touchUpInside)
        backgroundView.addSubview(submitBtn)
        self.addSubview(backgroundView)
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
